package io.renren.modules.lanling.service.impl;

import cn.hutool.core.lang.Validator;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.lanling.dao.SignUpRecordDao;
import io.renren.modules.lanling.entity.SignUpRecordEntity;
import io.renren.modules.lanling.service.SignUpRecordService;


@Service("signUpRecordService")
public class SignUpRecordServiceImpl extends ServiceImpl<SignUpRecordDao, SignUpRecordEntity> implements SignUpRecordService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        EntityWrapper<SignUpRecordEntity> entityWrapper = new EntityWrapper<>();

        Object name = params.get("name");
        if (Validator.isNotEmpty(name)) {
            entityWrapper.like("real_name", name.toString());
        }

        Object subjectId = params.get("subjectId");
        if (Validator.isNotEmpty(subjectId)) {
            entityWrapper.eq("subject_id", subjectId);
        }

        Page<SignUpRecordEntity> page = this.selectPage(
                new Query<SignUpRecordEntity>(params).getPage(), entityWrapper);

        return new PageUtils(page);
    }

}
